package com.onec.service.trade.dao;

import com.onec.service.api.dao.BaseRepository;
import com.onec.service.trade.entity.KBinInfo;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.RepositoryDefinition;

/**
 * @author ONEC
 */
@RepositoryDefinition(domainClass = KBinInfo.class, idClass = Long.class)
public interface KBinRepository extends BaseRepository<KBinInfo, Long> {

    /**
     * 获取卡bin 信息
     *
     * @param cardNo
     * @return
     */
    @Query(value = "SELECT id,MAX( kbin ) AS kbin,bank_name,bank_code,type FROM t_kbin_info WHERE substring( ?1, 1, LENGTH(kbin)) = kbin ", nativeQuery = true)
    KBinInfo findByCard(String cardNo);

}
